﻿@{
    ViewBag.Title = "";
    var id = Model != null ? Model.ID : 0;
}
@using ZBJF.Warranty.BLL
@using ZBJF.Warranty.WebProvider
@model ZBJF.Warranty.Model.ProductModels
<ul class="nav nav-tabs">
    <li><a href="/ProductModels/">设备型号列表</a></li>
    <li class="active"><a href="/ProductModels/Edit/@id">@(id > 0 ? "编辑设备型号" : "添加设备型号")</a></li>
</ul>
@using (Html.BeginForm("SaveProductModel", "ProductModels", FormMethod.Post, new { id = "inputForm", name = "inputForm", @class = "form-horizontal", enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(c => c.ID)
    @Html.HiddenFor(c => c.ImgUrl)
    <div class="control-group">
        <label class="control-label">设备型号名称：</label>
        <div class="controls">
            @Html.TextBoxFor(m => m.ModelName, new { validate = "{required:true,messages:{required:'请输入设备型号名称'}}", onkeyup = "BrandChange()" })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">品牌：</label>
        <div class="controls">
            @Html.DropDownListFor(m => m.BrandId, ConvertToSelector.Instance.ProductBrandConvertToSelectList(), new {validate = "{required:true,messages:{required:'请选择品牌'}}"})
        </div>
    </div>
      <div class="control-group">
        <label class="control-label">手机屏幕类型：</label>
        <div class="controls">
            @Html.DropDownListFor(m => m.ScreenType, ConvertToSelector.Instance.EnumTypeConvertToSelectList(typeof(ZBJF.Warranty.Common.Enums.Data.ScreenTypeEnum)), new { validate = "{required:true,messages:{required:'请选择屏幕类型'}}" })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">排序：</label>
        <div class="controls">
            @Html.TextBoxFor(m => m.Sort, new { maxlength = 4 })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">图片：</label>
        <div class="controls">
            <input type="file" name="ImgUrl" />
            <img src="@(Model!=null?Model.ImgUrl:"")" class="img-thumbnail preview" />
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">备注：</label>
        <div class="controls">
            @Html.TextAreaFor(m => m.Remark, new { style = "width:500px", maxlength = 1000 })
        </div>
    </div>
    <div class="control-group">
        <label class="control-label"></label>
        <div class="controls">
            <label>
                @Html.CheckBox("IsAvailable", Model == null ? true : Model.IsAvailable)
                是否可用
            </label>
        </div>
    </div>
    <div class="form-actions">
        <input id="btnSubmit" class="btn btn-primary Edit-R" type="button" value="保存" onclick="loading(this)">
        <input id="btnCancel" class="btn" type="button" value="重置" onclick="reset()">
    </div>
}
@section scripts
{
    @Scripts.Render("~/Bundles/ImagePreview")
    <script type="text/javascript">
        $(function () {
            $("img.preview").preview();
        });
        function reset() {
            document.getElementById("inputForm").reset();
        }
        function loading(_this) {
            if ($("#inputForm").valid()) {
                _this.disabled = 'disabled';
                document.getElementById("inputForm").submit();
            }
        }
    </script>
}
